#include<unistd.h>
#include<iostream>

int main()
{
    int pipefd[2] = {0};
    int pid;
    if(pipe(pipefd)<0)
    {
        perror("pipe");
    }
    pid = fork();
    if(pid == 0)
    {
        char buf[]="c++祖师爷本甲尼";
        /*write(pipefd[1],buf,sizeof(buf));*/
        sleep(10);
        _exit(0);
    }
    else if(pid >0)
    {
        wait();
        char str[50]={0};
        read(pipefd[0], str, sizeof(str));
        printf("str=[%s]\n", str); // 打印数据
        
    }
    return 0;
}